
// pages/user/address/address.js
const urls = require('../../../utils/url.js').urls;
const http = require('../../../utils/url.js').http
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dz: ''
  },
  getUserLocation: function () {
    //地址选择
    let that = this;

    wx.authorize({
      scope: 'scope.userLocation',
      success: (res) => {
        console.log('成功：', res)
         wx.chooseLocation({
                success: function (res) {
                  console.log(res)

                  that.setData({
                    dz: res.address + res.name
                  })
                },
              })
      },
      fail: (res) => {
        console.log('失败：', res)
      },
    })



  
  },
  fromSubmit:function(event){
    var that = this
    var zdm = 'dompany_address';

    var param = {
      openid: app.globalData.openid, //openid
      zdm: zdm, //字段名
      zdz: that.data.dz //字段值
    };
    http(urls.getUserUpdate, param, function (res) {
      console.log(res)
      if (res.code == 0) {
        wx.navigateBack({
        })
        wx.showToast({
          title: res.msg,
        })
      }
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
         var  that =this
         that.setData({
           dz:wx.getStorageSync("user_name")
         })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})